package com.example.demo.common.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * Rest API的统一数据返回格式。
 * @author Admin
 */
@ApiModel(description = "接口统一响应数据模型")
public class Response {
	@ApiModelProperty(value = "响应状态码")
	private int code; // 返回的数据的状态码。
	@ApiModelProperty(value = "状态提示信息")
	private String message; //数据提示信息。
	@ApiModelProperty(value = "响应的实际数据")
	private Object data; //返回的数据。
	public static Response error(int code,String messge,Object data) {
		return new Response(code,messge,data);
	}
	public static Response success(Object data) {
		return new Response(200,"ok",data);
	}
	public Response() {}
	public Response(int code,String message,Object data) {
		this.code = code;
		this.message = message;
		this.data = data;
	}
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
}
